package com.android.Bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.android.DBTools.ADUS;
import com.android.DBTools.DBConnection;
import com.android.ObjectBean.NationPolicyObjectList;

import net.sf.json.JSONArray;

public class NationalPolicyBean {
	public String nationPolicyList() throws ClassNotFoundException, SQLException{
		String sql="SELECT * FROM nationalPolicy;";
		ResultSet rs =ADUS.selectData(sql);
		List<NationPolicyObjectList> nplist=new ArrayList<NationPolicyObjectList>();
		while(rs.next()){
			NationPolicyObjectList np=new NationPolicyObjectList();
			np.setNpid(rs.getString(rs.findColumn("npid")));
			np.setNptitle(rs.getString(rs.findColumn("nptitle")));
			np.setNpcontent(rs.getString(rs.findColumn("npcontent")));
			np.setNpdate(rs.getString(rs.findColumn("npdate")));
			nplist.add(np);
		}
		DBConnection.closeCon();
		JSONArray json=JSONArray.fromObject(nplist);
		return json.toString();
	}
}
